package com.saclub.app.handler;

import java.util.List;

import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.ButterKnife;

import com.saclub.app.R;
import com.saclub.app.bean.page.NewsListPage;
import com.saclub.app.bean.part.News;
import com.saclub.app.fragment.CommonGirdFragment;
import com.saclub.app.utils.ImageUtils;

public class SectionResponseHandler extends MyBaseHttpResponseHandler<CommonGirdFragment, NewsListPage> {

	@Override
	public void deal() {

		List<News> newsList = page.getNewslist();
		caller.setNewsList(newsList);

			//名称
			String[] names = caller.getResources().getStringArray(R.array.grid_item_name_array);
			String[] colors = caller.getResources().getStringArray(R.array.grid_item_color_array);

			for (int i = 0; i < caller.getGirdItemViewList().size(); i++) {

				View itemView = caller.getGirdItemViewList().get(i);

				View itemMarkLayout = ButterKnife.findById(itemView, R.id.id_gird_item_mark_layout);
				TextView itemText = ButterKnife.findById(itemView, R.id.id_gird_item_mark_text);
				ImageView itemImage = ButterKnife.findById(itemView, R.id.id_gird_item_img);

				itemText.setText(names[i]);
				itemMarkLayout.setBackgroundColor(Color.parseColor(colors[i]));
				
				//赋值
				News news = newsList.get(i);
				String url = news.getNewImage();
				ImageUtils.load(itemImage, url);
				
				itemMarkLayout.setVisibility(View.GONE);

		}

	}
}